00e4a6d97872d787896dbf5fb0bf898b88029691,app/src/main/java/de/kuschku/quasseldroid_ng/ui/editor/AdvancedEditor.java,AdvancedEditor,toggleForeground,#number#number#number#,108

Before Change



    public void toggleForeground(int start, int end, @ColorInt int color) {
        boolean isColored = false;
        for (ForegroundColorSpan span : editText.getText().getSpans(start, end, ForegroundColorSpan.class)) {
            if ((editText.getText().getSpanFlags(span) & Spanned.SPAN_COMPOSING) != 0) continue;

            isColored = span.getForegroundColor() == color && (editText.getText().getSpanStart(span) == start && editText.getText().getSpanEnd(span) == end);
            editText.getText().removeSpan(span);

            if (isColored) break;
        }
        if (!isColored) {
            editText.getText().setSpan(new ForegroundColorSpan(color), start, end, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        }

After Change


    }

    public void toggleForeground(int start, int end, int color) {
        removeSpans(start, end, ForegroundColorSpan.class, foregroundColorSpan -> {
            if ((foregroundColorSpan instanceof IrcForegroundColorSpan)) {
                return (IrcForegroundColorSpan) foregroundColorSpan;
            } else {
                int id = context.themeUtil().res.colorToId(foregroundColorSpan.getForegroundColor());
                if (id != -1) {
                    return new IrcForegroundColorSpan(id, context.themeUtil().res.mircColors[id]);
                } else {
                    return null;
                }
            }
        }, true);

        if (color != -1) {
            editText.getText().setSpan(new IrcForegroundColorSpan(color, context.themeUtil().res.mircColors[color]), start, end, Spanned.SPAN_MARK_MARK);